<table class="show_table">
	<tr>
		<td>
			<p>
			  	<h1 class="show_title"> 
					<%=h @code.title  %>
			  		<a class="show_title_a">
			  			<br/>by  
						<%= link_to @code.getAuthorName, user_path(@code.getAuthorName), :class => "show_title_a2" %>
					</a>
				</h1>
			</p>
		</td>
		<td class="show_table_td2">
			<p>
				<%=h @code.getProgLangName %>
				/
				<%=h @code.getCategoryName %>
			</p>
		</td>
	</tr>
</table>


<table class="show_description">
	<tr>
		<td>
			<p>
  				<p><b class="show_description_b">Description:</b></p>
  				<a class="show_description_a"><%= @code.description %></a>
			</p>
		</td>
	</tr>
</table>


<p><b class="show_code_b">Code:</b></p>
<% if @prog_lang_brush == nil %> <pre class="brush: cpp;"> <% else %> <pre class="brush: <%= @prog_lang_brush %>;"> 	<% end %>
<%=h @code.code_body %></a>
</pre>


					
					
<!--
<p>
  <b>Tag:</b>
  <%=h @code.tag %>
</p>
-->



<!--
<p>
  <b>Shortdescription:</b>
  <%=h @code.shortdescription %>
</p>
-->

<!-- CODE INFO -->
<!-- user, cat, type and stuff, in one line. -->
<!-- TODO: make links instead of titles -->
<!--<b>User:</b>-->


<!--
<b>Type:</b>
<%=h @code.getTypeName %>
-->

<!-- COMMENT AREA -->
<!-- Separated with horizontal line at teh moment, TODO: use something nicer :) -->

<% if @isPrivate == false %> <!-- if code is private, comments, grades and stuff show is uneccessary -->

<!-- comment input form -->
<p style="text-align: right;">
<% if @canedit == true %>
	<%= link_to 'Edit', edit_code_path(@code), :class => "default_button_class" %>
<% end %>
</p>


<br/><br/><br/>
<table  class="show_code_rateandcomment">
	<tr>	
		<td>
			<table class="code_reply">	
				<% if @CodeReply != -1%>
					<tr>
						<td>
							<a  class="show_title_a2">This code is a reply to</a> <%= link_to @CodeReply.title, @CodeReply, :class => "show_title_a1" %>
						</td>
					</tr>
				<% end%>
				
				<% if @CodeReplies.length == 0%>
					<tr>
						<td>
							<a  class="show_title_a2">This code has no responses.</a>
						</td>
					</tr>
				<% end%>
				
				<% if @CodeReplies.length !=0%>
					<tr>
						<td>
							<p><a  class="show_title_a2">This code has responses :</a></p> 
						</td>
					</tr>
					
					<% for codeR in @CodeReplies %>
						<tr>
							<td>
								<a  class="show_title_a1"> - </a><%= link_to codeR.title, codeR, :class => "show_title_a1" %>
							</td>
						</tr>
					<% end%>
				<% end %>
		
				<% if @cancomment == true %>
				<tr>
					<td class="add_response_td">
						<p><%= link_to 'Add Response', { :controller => 'codes', :action => 'new', :response => '1', :parentID => @code.id }, :class => "show_title_a3" %></p>
					</td>
				</tr>
				<% end %>
			</table>
		</td>
	
		<td class="show_code_ilike">
			<table class="ilike_table">	
				<tr>
					<td>
						<p>
							Positive:<p> <%= @gradesPlus %> </p>
						</p>
					</td>
					<td>
						<p>
							Negative: <p> <%= @gradesMinus %> </p>
						</p>
					</td>
				</tr>
			</table>
	
	
					
			<table style="margin-right: 0%; margin-left: auto;">		
				<% if @cancomment == true %>	
						<tr>
							<% if @gradeUser == 0 %>
								<td>
									<%= button_to " ", {:controller => "codes", :action => "createGrade", :valueX => "1" , :userXid => session[:user_id], :codeXid => @code.id }, :class => "like_button" %>
								</td>
								<td>
									<%= button_to " ", {:controller => "codes", :action => "createGrade", :valueX => "-1" , :userXid => session[:user_id], :codeXid => @code.id }, :class => "dislike_button" %>
								</td>
							<% elsif @gradeUser == 1 %>
								<td>You already like this code,<br/>change your mind?</td>
								<td>
									<%= button_to " ", {:controller => "codes", :action => "gradeChange", :valueX => "-1" , :userXid => session[:user_id], :codeXid => @code.id }, :class => "dislike_button" %>
								</td>
							<% elsif @gradeUser == -1 %>
								<td>You already dont like this code,<br/>change your mind?</td>
								<td>
									<%= button_to " ", {:controller => "codes", :action => "gradeChange", :valueX => "1" , :userXid => session[:user_id], :codeXid => @code.id }, :class => "like_button" %>
								</td>
							<% end %>
						</tr>
				<% end %>			
			</table>
		</td>
	</tr>
</table>








<!-- comments show section -->


		<p> 
			<b class="show_code_b"> Comments: </b>
		</p>
		
		
		<table  class="comments_table">
			<% @comments.each do |comment| %>
  				<tr>
  					<td class="comments_table_td1" style="width: 10%">
						<%= image_tag (comment.getPicturePath, :size => "50x50") %>
  					</td>
					<td class="comments_table_td2" style="width:90%">
						<%= link_to comment.getAuthorName, user_path(comment.getAuthorName), :class => "show_title_a2" %> 
						said:
						<br />

						<p><pre><%=h comment.content %></pre></p>
					</td>
  				</tr>
			<% end %>	
		</table>

<table>
	<tr>
				<% if @cancomment == true %>
					<td class="show_code_makecomment">
						<!-- create layout for insertion of comment -->
						<% form_tag :action => 'create_comment' do %>
							
							<!-- used for passing this code_id -->
							<input type="hidden" name="code_id" value="<%= @code.id %>"/>	
					
							<p>
					    			<%= text_area :comment, :content, :class => "comment_text_area" %>
							</p>
					
							<p style="padding-left: 110px;">
					    			<%= submit_tag 'Comment', :class => "submit_button" %>
					  		</p>	
						<% end %>
					</td>
				<% end %>
			</tr>
	</table>


<br/><br/><br/>
<p>

<% end %> <!-- END OF if @isPrivate -->

<!-- link edit, do only if authorised to do so -->


<!-- link back -->
</p>
